package com.gdcn.zb.sys.service.impl;

import java.util.List;

import com.gdcn.zb.base.BaseService;
import com.gdcn.zb.base.exception.DaoException;
import com.gdcn.zb.base.exception.ServiceException;
import com.gdcn.zb.sys.dao.IFunctionDao;
import com.gdcn.zb.sys.service.IFunctionService;
import com.gdcn.zb.sys.valueobject.Function;

public class FunctionServiceImpl extends BaseService implements IFunctionService {
	private IFunctionDao functionDao ; 
	
	public void setFunctionDao(IFunctionDao functionDao) {
		this.functionDao = functionDao;
	}

	public void createFunction(Function function) throws ServiceException {
		try{
			functionDao.createFunction(function);
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
	}

	public void deleteFunction(String id) throws ServiceException {
		try{
			functionDao.deleteFunction(id);
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
	}

	public Function findFunctionById(String id) throws ServiceException {
		Function function = null;
		try{
			function = functionDao.findFunctionById(id);
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
		return function;
	}

	public List<Function> findFunctionByFunctionName(String functionName)throws ServiceException {
		// TODO Auto-generated method stub
		return null;
	}

	public void updateFunction(Function function)throws ServiceException {
		try{
			functionDao.updateFunction(function);
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
	}

	public List<Function> listFunctionOfAll() {
		List<Function> list = null;
		try{
			list = functionDao.listFunctionOfAll();
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
		return list;
	}

	public void deleteFunction(String[] id) throws ServiceException {
		if(id != null){
			for(int i=0;i<id.length;i++){
				deleteFunction(id[i]);
			}
		}
		
	}

}